﻿using System;

namespace DataCoreTechnologies.SqlServer
{
   /// <summary>
   /// Contains information about a parameter belonging to a stored procedure or function.
   /// </summary>
   public sealed class Parameter
   {
      #region Public
      //Properties
      /// <summary>
      /// A number that uniquely identifies this class instance.
      /// </summary>
      public Guid InstanceId { get; private set; }
      /// <summary>
      /// The stored procedure this parameter belongs to.
      /// </summary>
      public StoredProcedure StoredProcedure { get; private set; }
      /// <summary>
      /// The function this parameter belongs to.
      /// </summary>
      public Function Function { get; private set; }
      /// <summary>
      /// The title used to identify this parameter within the database.
      /// </summary>
      public string Name { get; internal set; }
      /// <summary>
      /// The system type this parameter derives from.
      /// </summary>
      public SystemType SystemType { get; internal set; }
      /// <summary>
      /// When appropriate the user type this parameter derives from.
      /// </summary>
      public UserType UserType { get; internal set; }
      /// <summary>
      /// A short explanation of the purpose of this parameter.
      /// </summary>
      public string Description { get; internal set; }
      /// <summary>
      /// When appropriate the maximum length allowed by this parameter.
      /// </summary>
      public int Length { get; internal set; }
      /// <summary>
      /// When appropriate the level of precision used by this parameter.
      /// </summary>
      public int Precision { get; internal set; }
      /// <summary>
      /// When appropriate the scale used by this parameter.
      /// </summary>
      public int Scale { get; internal set; }
      /// <summary>
      /// The order this parameter is being passed into its stored procedure or function.
      /// </summary>
      public int Order { get; internal set; }
      /// <summary>
      /// Indicator stating whether this parameter can be used to return values.
      /// </summary>
      public Boolean IsOutput { get; internal set; }
      /// <summary>
      /// Indicator stating whether this parameter contains a cursor reference.
      /// </summary>
      public Boolean IsCursorReference { get; internal set; }
      /// <summary>
      /// Indicator stating the formula used to calculate the default value for this parameter.
      /// </summary>
      public string DefaultValue { get; internal set; }
      #endregion
      #region Internal
      //Constructor
      /// <summary>
      /// Creates a parameter and associates it to the stored procedure specified by the parameter.
      /// </summary>
      /// <param name="container">The stored procedure this parameter belongs to.</param>
      internal Parameter(StoredProcedure container)
      {
         InstanceId = System.Guid.NewGuid();
         StoredProcedure = container;
         Description = "";
      }
      /// <summary>
      /// Creates a parameter and associates it to the function specified by the parameter.
      /// </summary>
      /// <param name="container">The function this parameter belongs to.</param>
      internal Parameter(Function container)
      {
         InstanceId = System.Guid.NewGuid();
         Function = container;
         Description = "";
      }
      //Properties
      /// <summary>
      /// A number used to uniquely identify this parameter within the database.
      /// </summary>
      internal int Id { get; set; }
      #endregion
   }
}
